Skip to content

fix: give fields with the same exported name unique names - #30

Closed
jayhemnani9910 wants to merge 1 commit into
twpayne:masterfrom
jayhemnani9910:fix/unique-field-names
Closed

jayhemnani9910 wants to merge 1 commit into
twpayne:masterfrom
jayhemnani9910:fix/unique-field-names

Conversation

@jayhemnani9910

Copy link
Copy Markdown

When two JSON keys map to the same Go name, the generated struct has two fields with that name and does not compile. GitHub API issues and pull requests hit this through reactions, whose "+1" and "-1" keys both become _1; {"id":1,"ID":2} and {"userId":1,"user_id":2} do the same.

Field names are now made unique per struct: a name that is already taken gets a numeric suffix (ID2, or _1_2 when the name ends in a digit). Properties are already sorted, so the output is stable.

Added a duplicate_field_names case to TestObserveJSONGoCode; it fails on master. go test ./... passes, and types generated from the GitHub issues API now compile.

@twpayne

twpayne commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Closing AI slop PR.

@twpayne twpayne closed this Nov 20, 2026
@twpayne

twpayne commented Nov 20, 2026

Copy link
Copy Markdown
Owner

These AI slop PRs are so annoying. This one is a perfect example of how bad they can be.

  • It's clearly AI slop. At the time of writing, the PR author has created 732 commits in 217 different repositories in the last 20 days. This is a meat proxy, not a person.
  • There is no evidence that the PR author actually uses this repo. They're just green square farming.

The PR is wrong on many levels:

  • At a low level, the algorithm used is dumb. It uses trial-and-error to de-duplicate when an obvious deterministic algorithm exists.
  • The code is "bolted on" to the existing code, accumulating complexity and technical debt.
  • At a medium level, it confuses multiple issues: de-duplicating case-sensitivity ID and id is quite different to de-duplicating property names with symbols in them like -1 and +1.
  • It fails to understand the wider context of the project. -1 is not just a property name, it's also a kebab-cased property name, and the PR does not address what the correct behavior should be for a property like -a.
  • At a high level, it shouldn't even exist. If you're parsing JSON from GitHub's API then you should use GitHub's well-defined schemas and client libraries, not this library.

The author should be ashamed of themselves for foisting this generated slop on others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants